package com.example.javatest;

import java.util.ArrayList;
import java.util.List;

public class MyClass {

    public static void main(String[] args) {


        List<RemoveTestBean> list = new ArrayList<>();
        RemoveTestBean bean01 = new RemoveTestBean(1, "test 01");
        RemoveTestBean bean02 = new RemoveTestBean(2, "test 02");
        RemoveTestBean bean03 = new RemoveTestBean(3, "test 03");

        list.add(bean01);
        list.add(bean02);
        list.add(bean03);

        for (RemoveTestBean bean : list) {
            System.out.println(bean.toString());
        }

        bean02.setName("test 02 change");
        list.remove(bean02);

        for (RemoveTestBean bean : list) {
            System.out.println(bean.toString());
        }

    }


    static class RemoveTestBean {
        private int id;
        private String name;

        public RemoveTestBean(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "RemoveTestBean{" +
                    "id=" + id +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}
